/**
 * 
 */
package com.netscenery.yang.parser;

import java.util.ArrayList;

import com.netscenery.util.ErrTag;

/**
 * @author llly
 *
 */
public class YangParserException extends Exception{
	private YangParserEnv env;
	private ErrTag errorTag;
	private String description;
	private int errLine;
	private int errColumn;
	
	
	//private LangMode lang;
	
	/**
	 * @return the errLine
	 */
	public int getErrLine() {
		return errLine;
	}

	/**
	 * @param errLine the errLine to set
	 */
	public void setErrLine(int errLine) {
		this.errLine = errLine;
	}

	/**
	 * @return the errColumn
	 */
	public int getErrColumn() {
		return errColumn;
	}

	/**
	 * @param errColumn the errColumn to set
	 */
	public void setErrColumn(int errColumn) {
		this.errColumn = errColumn;
	}

	public YangParserException(YangParserEnv env,ErrTag errorTag,int curLine, int curColumn, String description){
		this.env = env;
		this.errorTag = errorTag;
		this.setErrLine(curLine);
		this.setErrColumn(curColumn);
		this.setDescription(description);
	}

	/**
	 * @return the errorTag
	 */
	public ErrTag getErrorTag() {
		return errorTag;
	}

	/**
	 * @param errorTag the errorTag to set
	 */
	public void setErrorTag(ErrTag errorTag) {
		this.errorTag = errorTag;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		if (null != this.env){
			if (null != env.getFilename()){
				sb.append("@" + env.getFilename() + "  ");
			}
		}
		switch(this.errorTag){
		case ERROR:{
			sb.append("Error:");
			break;
		}
		case WARNING:{
			sb.append("Warning:");
			break;
		}
		case INFO:{
			sb.append("Info:");
			break;
		}
		case DEBUG:{
			sb.append("Debug:");
			break;
		}
		default:{
			return null;
		}
		}
		
		sb.append("line:");
		sb.append(this.errLine);
		sb.append(" ");
		sb.append("column:");
		sb.append(this.errColumn);
		sb.append(" ");
		sb.append(this.description);
		sb.append("\n");
		
		return sb.toString();
		
	}
	
	
}
